from selenium import webdriver
from selenium.webdriver.chrome.options import Options

#初始化各种浏览器的driver，并对drver进行设置
def initDriver(browerType="chrome",timemout=10,isMaximize=True,isHeadless=False):
    driver=None
    if browerType=="chrome":
        chrome_options = Options()
        if isHeadless:
            chrome_options.add_argument("--headless")
        driver = webdriver.Chrome(options=chrome_options)
    elif browerType=="firfox":
        driver=webdriver.Firefox()
    elif browerType=="ie":
        driver=webdriver.Ie()
    else:
        driver = webdriver.Chrome()

    if timemout!=0:
        driver.implicitly_wait(timemout)

    if isMaximize:
        driver.maximize_window()

    return driver